#include <iostream>
#include <string>

using namespace std;

bool checkNumber(char strChek)
{
	if (strChek >= '0' && strChek <= '9')
	{
		//cout<<"dung so "<<strChek<<endl;
		return true;
	}
	//cout<<"sai so "<<strChek<<endl;
	return false;
}

bool checkChar(char strChek)
{
	if (strChek == '-')
	{
		//cout<<"dung char: "<<strChek<<endl;
		return true;
	}
	//cout<<"sai char "<<strChek<<endl;
	return false;
}


int main()
{
	//012345678910
	//123-123-123	
	string strTets;
	cout<<"nhap ma ID theo dung dinh dang (xxx-xxx-xxx): ";
	getline(cin,strTets);
	cout<<"do dai cua str: "<<strTets.length()<<endl;
	
	for (int i = 0; i < strTets.length(); i++)
	{
		if (strTets.length() == 11)
		{
			if (i == 3 || i == 7)
			{
				checkChar(strTets[i]);
				if (checkChar(strTets[i]) == false)
				{
					cout<<"ban da nhap sai, vui long nhap lai dung format(xxx-xxx-xxx)"<<endl;
					break;
				}
				i++;
			}
			checkNumber(strTets[i]);
			if (checkNumber(strTets[i]) == false)
			{
				cout<<"ban da nhap sai, vui long nhap lai dung format(xxx-xxx-xxx)"<<endl;
				break;
			}
		}
		else
		{
			cout<<"ban da nhap sai dinh dang (xxx-xxx-xxx)"<<endl;
			break;
		}
	}
	system("pause");
}
